﻿/*!	@file	r_skeleton_score.h
	@brief	テストスコア
Copyright (c) 2010 Yuya Yamaguchi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _SKELETON_SCORE_H_
#define _SKELETON_SCORE_H_

#include "lib/score/r_score_client.h"

#include "lib/math/r_math_matrix44.h"
#include "lib/math/r_math_vector3.h"
#include "lib/math/r_math_vector2.h"

namespace r{
	namespace draw{
		class RenderTarget;
		class DepthStencil;
		class VertexShader;
		class PixelShader;

		class InputLayout;
		class VertexBuffer;
		class IndexBuffer;
		class ConstantBuffer;

		class RasterizerState;
		class DepthStencilState;

		class Texture2D;
	}
	namespace render{
		class ObjSphere;
	}

	namespace raytrace{
		class Render;
		class Object;
		class Scene;
		class Buffer;
		class Camera;
	}
}

class cSkeletonScore : public cRScoreClient {
	RRTTI_REFLECTION_DECLARE
public:
	//! コンストラクタ
	cSkeletonScore();
protected:
	//! デストラクタ
	virtual ~cSkeletonScore();
public:
	//! 初期化
	/*!
	*/
	virtual	void	init();
	//! ロード確認
	/*! この関数がtrueを返すことで次回よりupdateが呼ばれるようになる
	*/
	virtual r_bool	checkLoad();
	//! 同期更新
	/*!
	*/
	virtual void	update();
	//! 破棄
	/*!
	*/
	virtual void	destroy();
protected:
	struct vertexType {
		r::math::Vector3D		pos;
		r::math::Vector2D		uv;
	};
	struct	constantMatrix {
		r::math::Matrix44		prjMat;
	};
	struct	constantParams {
		r::math::Vector2D		clipPlane;
		r::math::Vector2D		sampleDistance;
		r_si32			loopCount;
	};
private:
#if 0
	virtual	void	createSphere();
	virtual	void	createPlane();
	virtual	void	createScreen();
	virtual	void	createBox();
#endif
	// レイトレースの初期化
	void			initRaytrace();
	// レイトレースの更新
	void			updateRaytrace();
	// レイトレースの破棄
	void			destroyRaytrace();
private:
	r::draw::RenderTarget*		target;
	r::draw::DepthStencil*		depth;

	r::draw::VertexShader*		defVS;
	r::draw::PixelShader*		defPS;

	r::render::ObjSphere*		sphereData;

	r::draw::ConstantBuffer*	t3dmatBuff[3];
	r::draw::ConstantBuffer*	t2dmatBuff;
	r::draw::ConstantBuffer*	paramBuff;

	r::draw::DepthStencilState*	depthStateEqual;
	r::draw::RasterizerState*	raster;

	r::raytrace::Render*		raytraceRender;
	r::raytrace::Buffer*		raytraceBuffer;
	r::raytrace::Camera*		raytraceCamera;
	r::raytrace::Object*		raytraceSphere;
	r::raytrace::Scene*			raytraceScene;
	r::draw::Texture2D*			raytraceResultTexture;
};


#endif // _SKELETON_SCORE_H_
